
<%@page import="album.AlbumVo"%>
<%@page import="album.Album"%>
<%@page import="java.util.Vector"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Album_list.jsp</title>
<link rel="stylesheet" href="http://fonts.googleapis.com/earlyaccess/nanumgothic.css" />
<style>
* {margin: 0; padding: 0;}
a {text-decoration:none;}
ul li, ol li {list-style-type: none;}

.tile2{
	/* background-color:green; */
	position:absolute;
	height:510px;
	float:left;
	top:182px;
	left:1050px;
	font-size: 14px;
	font-family: 'Nanum Gothic', sans-serif;
	
}

/* title */
.table-number, .table-subject, .table-file, .table-date{
	line-height: 250%;/* 줄 간격 */
	display: table-cell;
	background-color: #160952;
	font-family: 'Nanum Gothic', sans-serif;
	font-size: 14px;
	color:white;
}

.table-title{background-color:gray;}
.table-number{width:50px; float:left;}
.table-subject{width:156px; float:left;}
.table-file{width:100px; float:left;}
.table-date{width:100px; float:left;}
#list_line {width: 100%; height: 1px; float:left;}

/* list */
.list-serial, .list-subject, .list-filename, .list-date{
	display: table-cell;
	line-height: 200%; /* 줄 간격 */
	font-family: 'Nanum Gothic', sans-serif;
	font-size: 13px;
	color: black;
}

.title-list{width:100%; background-color:blue;}
.list-serial{width:50px;  float:left; text-align:center; }
.list-subject{width:156px;  float:left; text-align:center; }
.list-filename{width:100px;  float:left; text-align:center; }
.list-date{width:100px;  float:left; text-align:center; }

.btn{/* background-color:white; */margin:0 auto; margin-top:20px; margin-right:10px;}
.Page{margin:0; margin-top:70px;}
#page_button{border:0 solid; background-color:transparent;}
.count{float:left; margin-top:-17px;}
#btnWrite{float:right; margin-top:-17px;}

</style>
<script>
	window.onload = function(){
		var btn = document.getElementById("btnWrite");
		btn.onclick=function(){
			location.href="Main.jsp?inc_content=Album1.jsp?inc_right=../album/Album1-write.jsp";
		}
	};
	function fileDownLoad(filename){
		// 파일 다운로드 스크립트
		// 새 창을 열어 첨부 파일을 무조건 다운로드 하도록
		url ="../album/Album1_FiledownLoad.jsp?filename=" + filename;
		win = window.open(url, "win", "");
		
	}
	function goPage(page){
			/* alert("dddd"); */
			var ff = document.search;
			ff.nowPage.value = page;
			ff.action = "Main.jsp?inc_content=Album1.jsp?inc_right=../album/Album_list.jsp";
			ff.submit();
	}
</script>
</head>
<body>
<jsp:useBean id="albumVo" class="album.AlbumVo"/>
<jsp:setProperty property="*" name="albumVo"/>

<%

		//검색어 세션 처리 
		if (request.getMethod().equals("POST")) { // POST 방식일 경우에만, 세션에 저장
			session.setAttribute("find", albumVo.getFind());
			
		} else { // GET 방식일 경우, 세션이 존재할 경우메나 setter
			if (session.getAttribute("find") != null)
				albumVo.setFind((String) session.getAttribute("find"));
		}
	
		 // 페이지 정보 유지 
		if(request.getParameter("nowPage") == null){
			if(session.getAttribute("nowPage") != null)
				albumVo.setNowPage((Integer)session.getAttribute("nowPage"));
		}
		else{
			session.setAttribute("nowPage", albumVo.getNowPage());
		}




Album album = new Album();
album.setVo(albumVo);
Vector<AlbumVo> vo = album.list();
String sessionID = (String)session.getAttribute("mid");
if (sessionID == null || sessionID == "") sessionID = "test";
%>
<div class="tile2">
   			<ul class="table-title">
     			<li class="table-number">번호</li>
      			<li class="table-subject">제목</li>
      			<li class="table-file">파일</li>
      			<li class="table-date">날짜</li>
      			<li id='list_line' style='background-color: #D2D2D2;'></li>
				<li id='list_line' style='background-color: #82B5DF;'></li>
      		</ul>
      		<%for(int i=0; i<vo.size(); i++){
      			AlbumVo av = vo.get(i);
      		%>
      		<ul class="title-list">
      			<li class="list-serial"><%=av.getSerial()%></li>
	      			<li class="list-subject">
	      			<%if(sessionID.equals("kdh2499")  || sessionID.equals("inzy") || sessionID.equals("ricu") || sessionID.equals("rkdrnr1404") || sessionID.equals("chy")){ %>
	      			<a href="Main.jsp?inc_content=Album1.jsp?inc_right=../album/Album1_view.jsp&serial=<%=av.getSerial()%>"><%=av.getSubject()%></a>
	      			<%}else{ %>
	      			<%=av.getSubject()%>
	      			<%} %>
	      			</li>
      			<li class="list-filename"><a href="#" onclick="fileDownLoad('<%=av.getFilename()%>')"><%=av.getFilename()%></a></li>
      			<li class="list-date"><%=av.getMdate()%></li>
      			<li id='list_line'	style='background-color: #D2D2D2; margin-top: 2px;'></li>
      		</ul>
      		<%} %>
      		<div id='list_line' style='background-color: #82B5DF; margin-bottom: 10px;'></div>
      		
      		
      		<div class="Page">
      		<form action="" method="post" name="search">
      		<%for(int p=album.getStartPage(); p<=album.getEndPage(); p++){ %>
      			<input type="button" value=<%=p%> id="page_button" onClick="goPage(<%=p%>)">
      		<%} %>
      		<%if(album.getNowBlock() < album.getTotBlock()){ %>
      		<input type="button" value="다음" onClick="goPage(<%=album.getEndPage()+1%>)" style="font-family: 'Nanum Gothic', sans-serif; font-size: 14px; color:black;">
      		<input type="button" value="맨끝" onClick="goPage(<%=album.getTotPage()%>)" style="font-family: 'Nanum Gothic', sans-serif; font-size: 14px; color:black;">
      		<%} %>
      		<input type="hidden" name="nowPage" value=<%=albumVo.getNowPage()%>>
      		</form>
      		</div>
      		
      		
      		<div class="count">
      				<ul>
      					<li>전체건수 : <%=vo.size()%></li>
      				</ul>
      			</div>
      		<input type="button" value="Upload" id="btnWrite" style="font-family: 'Nanum Gothic', sans-serif; font-size: 14px; color:black;">
      		<div class="btn">
      			<form name="search_from" method="post" action="Main.jsp?inc_content=Album1.jsp?inc_right=../album/Album_list.jsp&nowPage=1">
      			<input type="search" name="find" id="find" placeholder="검색해 주세요." value="<%=albumVo.getFind()%>" style="font-family: 'Nanum Gothic', sans-serif; font-size: 14px; color:black;">
      			<input type="submit" id="btnSearch" value="SEARCH" style="font-family: 'Nanum Gothic', sans-serif; font-size: 14px; color:black;">
      			<input type="hidden" name="nowPage" value=<%=albumVo.getNowPage()%>>
      			</form>
      		</div>
    </div>
</body>
</html>